import React, {Component} from 'react';
import {Button, Modal} from 'antd';
import Lng from "../common/lng";


class DetailModal extends Component {

    constructor(props) {
        super(props);
    }

    state = {
        visible: false,
    }
    showModal = () => {
        this.setState({
            visible: true,
        });
    }

    getForm() {
        return this.refs["form"].getForm();
    }

    handleOk = (e) => {
        this.hideModal();
    }

    hideModal() {
        this.setState({loading: false, visible: false});
    }

    render() {
        const {visible} = this.state;
        return (
            <Modal
                visible={visible}
                title={Lng.get("common.detail", {some: this.props.titleName})}
                onOk={this.handleOk}
                onCancel={this.handleCancel}
                width={500}
                closable={false}
                destroyOnClose={true}
                maskClosable={false}
                footer={[
                    <Button key="submit" type="primary" onClick={this.handleOk}>
                        {Lng.get("common.ok")}
                    </Button>
                ]}
            >
                {
                    <this.props.content ref={"form"} id={this.props.id}/>
                }
            </Modal>
        );
    }
}

export default DetailModal;